package com.jintian.smart.base.expression.expr.function;

import com.jintian.smart.base.api.system.provider.IDictProvider;
import com.jintian.smart.kernel.core.annotation.expr.ExprFn;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

@ExprFn(code = "")
@Component
public class DictFn {
    private static DictFn _INSTANCE;

    public DictFn() {
        _INSTANCE = this;
    }

    @DubboReference(check = false)
    IDictProvider dictProvider;

    private String _dictValue(String code, String dictKey) {
        return this.dictProvider.getDictDataLabel(code, dictKey);
    }

    @ExprFn(code = "dictValue", label = "获取字典值", group = "字典函数")
    public static String dictValue(String code, String dictKey) {
        return _INSTANCE._dictValue(code, dictKey);
    }
}
